import React from "react";
import { forwardRef } from "react";
import "./index.scss";
import { parseClass } from "@/utils/compUtils";

export type ButtonProps = {
  type?: "default" | "primary" | "success" | "info" | "warning" | "danger";
  children?: React.ReactNode;
  onClick?: React.MouseEventHandler<HTMLButtonElement>;
};

export const InnerButton: React.ForwardRefRenderFunction<
  HTMLButtonElement,
  ButtonProps
> = (props, ref) => {
  if (ref) {
    console.log(ref);
  }
  const { type = "default", children, onClick } = props;

  return (
    <button className={parseClass(["l-button", type])} onClick={onClick}>
      {children}
    </button>
  );
};

export const Button = forwardRef<HTMLButtonElement, ButtonProps>(InnerButton);
